package geometrie;

public class Gerade
{

    private Punkt startPos;

    private Punkt endPos;

    public Punkt getStartPos()
    {
        return startPos;
    }

    public void setStartPos(Punkt startPos)
    {
        if (startPos != null)
        {
            this.startPos = startPos;
        }
        else
        {
            this.startPos = new Punkt(0, 0);
        }
    }

    public Punkt getEndPos()
    {
        return endPos;
    }

    public void setEndPos(Punkt endPos)
    {
        if (endPos != null)
        {
            this.endPos = endPos;
        }
        else
        {
            this.endPos = new Punkt(0, 0);
        }
    }

    public Gerade(Punkt start, Punkt ende)
    {
        if (start != null)
        {
            this.startPos = new Punkt(start.getXKoordinate(), start.getYKoordinate());
        }
        else
        {
            this.startPos = new Punkt(0, 0);
        }
        if (ende != null)
        {
            this.endPos = new Punkt(ende.getXKoordinate(), ende.getYKoordinate());
        }
        else
        {
            this.endPos = new Punkt(0, 0);
        }
    }

    public double laenge()
    {
        if (startPos != null && endPos != null)
        {
            return startPos.abstand(endPos);
        }
        return Double.NaN;
    }

    public boolean istLaengerAls(Gerade g2)
    {
        if (g2 != null)
        {
            if ((startPos.abstand(endPos) > g2.startPos.abstand(g2.endPos)))
            {
                return true;
            }
        }
        return false;
    }

    public boolean equals(Gerade g2)
    {
        if (g2 != null)
        {
            if (startPos.getXKoordinate() == g2.startPos.getXKoordinate() && endPos.getXKoordinate() == g2.endPos.getXKoordinate() && startPos.getYKoordinate() == g2.startPos.getYKoordinate() && endPos.getYKoordinate() == g2.endPos.getYKoordinate())
            {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args)
    {
        Gerade g = new Gerade(null, null);
        System.out.println(g.startPos);
    }
}
